package icu.ac.kr.simpleRssReader.view;

import icu.ac.kr.simpleRssReader.provider.RssDBProviderConstant;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ChannelHead extends LinearLayout {
	
	TextView channelTitle;
	ImageView image;
	
	public ChannelHead(Context context, AttributeSet attrs) {
		super(context, attrs);
	
	channelTitle = new TextView(context);
	image = new ImageView(context);
	
	LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	
	addView(channelTitle, params);
	addView(image, params);
	
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.dispatchDraw(canvas);
	
		Paint paint = new Paint();
		paint.setColor(Color.GRAY);
		
		canvas.drawLine(10, 2, getMeasuredWidth() - 10, 2, paint);
		canvas.drawLine(10, getMeasuredHeight() -1, getMeasuredWidth() - 10, getMeasuredHeight() -1, paint);
		canvas.drawLine(10, 0, 10, getMeasuredHeight(), paint);
		canvas.drawLine(getMeasuredWidth() - 10, 0, getMeasuredWidth() - 10, getMeasuredHeight(), paint);
	}

	@Override
	public void setOrientation(int orientation) {
		// TODO Auto-generated method stub
		super.setOrientation(LinearLayout.HORIZONTAL);
	}

	public void bindData(String id)
	{
	
		channelTitle.setTypeface(Typeface.DEFAULT_BOLD);
		channelTitle.setText("Channel ID : " + id);
		image.setImageURI(RssDBProviderConstant.ICONURI);
		
	}
	

}
